home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Frameworks / Dragonsmith 1.1.1 / CW 4.5 Update / Dragon.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-04  |  9.8 KB  |  116 lines  |  [TEXT/MMCC]

  1. /*
  2.     Dragon.h
  3.     
  4.     Interface to Dragon.c
  5.  
  6.   Modified: 01 Jul 1994 by Francis H Schiffer, 3rd - remove indirect keyword,
  7.                            and fix calling sequence of SuspendAEvent
  8. */
  9.  
  10. #pragma once
  11.  
  12. #include    "AppleEventQueue.h"
  13. #include    "Preferences.h"
  14. #include    "FileUtils.h"
  15.  
  16. #define    prefDragonPrefs    0                // This class's preferences number (see Preferences.c)
  17.  
  18. // Structure of the 'DrPr' 128 resource
  19. typedef struct {
  20.     short    miscFlags;
  21.     short    reserved;
  22.     long        sleep[4];
  23.     short    depthLim;
  24. } DragonPrefsRec;
  25.  
  26. // Masks for use with miscFlags
  27. enum {
  28.     maskFilesOnly = 1,
  29.     maskResolveAliases = 2,
  30.     maskFollowAliasChain = 4,
  31.     maskAutoQuit = 8
  32. };
  33.  
  34. // Possible values for runState — are we in the foreground or background, and are we idle or are we busy (i.e., processing docs)?
  35. enum {
  36.     kFGIdle,        // binary …0000
  37.     kBGIdle,        // binary …0001
  38.     kFGBusy,    // binary …0010
  39.     kBGBusy        // binary …0011
  40. };
  41.  
  42. // Masks for use with runState
  43. //    If we're in the background, runState & maskInBG != FALSE
  44. //    If we're busy, runState & maskBusy != FALSE
  45. enum {
  46.     maskInBG = 1,    // binary …0001
  47.     maskBusy = 2        // binary …0010
  48. };
  49.  
  50. class Dragon {    /* fhs 1994 july 1 */
  51.  
  52.     protected:
  53.         FSSpec            *curDocFSS;        // Pointer to an FSSpec to the current file or folder (or volume)
  54.         PBRecUnion        *curDocPB;        // Pointer to a multi-purpose param block containing info about the current doc
  55.         short            dirDepthLimit;        // Recursively open folders and volumes to this level (0 == don't open
  56.                                         //    them, -1 == go down one level, etc.)
  57.         short            curDirDepth;        // Where are we now? — 0 == at top level, -1 == down one, etc.
  58.         Boolean            filesOnly;            // Do we ignore folders and volumes that appear at the lowest level?
  59.                                         //     (i.e., when curDirDepth == dirDepthLimit)
  60.         Boolean            resolveAliases;    // Resolve any aliases we end up with after opening folders and disks?
  61.         Boolean            followAliasChain;    // Resolve them all the way, or just one step of the way?
  62.         Boolean            useCustomFilter;    // Should we use the CustomFilterOne method to check each FSSpec?
  63.         TypeListHndl        acceptableTypes;    // List (derived from our 'FREF' resources) of all the types of things we
  64.                                         //    can digest
  65.  
  66.         OSType            prefsFileType;        // Our prefs file's type
  67.         Preferences        *preferences;        // Preferences-managing object
  68.         DragonPrefsRec    **dragonPrefs;    // Handle to the resource containing preferences used by Dragon
  69.                                         //    (provided so that subclasses can let the user change them)
  70.         short            appResFork;        // The application file's resource fork refNum
  71.         FSSpec            appFile;            // An FSSpec that identifies the dragon's application file
  72.         
  73.         OSType            signature;        // The dragon application's signature
  74.         short            runState;            // What state are we in — processing docs?  in the background?
  75.         long                sleepTime;        // Maximum number of ticks to yield to WaitNextEvent
  76.         long                sleepValue[4];        // One sleepTime value for each of the 4 states (see the enum above)
  77.         CursHandle        busyCursor;        // The cursor we show when we're busy
  78.         RgnHandle        cursorRgn;        // For WaitNextEvent
  79.         Boolean            running;            // Are we running?
  80.         Boolean            abortProcessing;    // Should we stop processing docs?
  81.         Boolean            autoQuit;            // Should we automatically quit after the first 'oapp' or 'odoc'?
  82.         Boolean            menusInstalled;    // Do we have working menus?
  83.         
  84.         AppleEventQueue    *aeQueue;        // Queue object used to manage suspended Apple events
  85.         short            numAEsPending;    // Number of Apple events that we've received but not yet processed
  86.         
  87.         MenuHandle        appleMenu;
  88.         MenuHandle        fileMenu;
  89.         MenuHandle        editMenu;
  90.         
  91.     public:
  92.                         Dragon (void);        // Constructor
  93.         virtual void        Start (void);
  94.         virtual void        Run (void);
  95.         virtual OSErr        DoOapp (AppleEvent *theAppleEvent, AppleEvent *theReply, long refcon);
  96.         virtual OSErr        DoOdoc (AppleEvent *theAppleEvent, AppleEvent *theReply, long refcon);
  97.         virtual OSErr        DoPdoc (AppleEvent *theAppleEvent, AppleEvent *theReply, long refcon);
  98.         virtual OSErr        DoQuit (AppleEvent *theAppleEvent, AppleEvent *theReply, long refcon);
  99.         virtual Boolean    WaitIdle (EventRecord *theEvent, long *sleep, RgnHandle *mouseRgn);
  100.         virtual void        StopRunning (OSErr err);
  101.         virtual void        Finish (void);
  102.  
  103.     protected:
  104.         virtual void        BeginProcessing (void);
  105.         virtual void        EndProcessing (void);
  106.         virtual void        StopProcessing (OSErr err);
  107.  
  108.         virtual Boolean    CanProcessDoc (void);
  109.         virtual Boolean    CustomFilterDoc (void);
  110.         
  111.         virtual OSErr        ProcessDroppings (AEDescList *docList);
  112.         virtual void        ProcessDoc (void);
  113.         virtual void        ProcessFile (void);
  114.         virtual void        ProcessDirectory (void);
  115.         virtual void        ProcessDocsInDirectory (short vRefNum, long dirID);
  116.         virtual void